/* eslint-disable */
// @ts-nocheck
let id = 0;
var scene;
function connect(div: HTMLDivElement) {
  return () => {
    const shaders = new GZ3D.Shaders();
    scene = new GZ3D.Scene(shaders);
    const iface = new GZ3D.GZIface(scene, "localhost:8080");
    const sdfparser = new GZ3D.SdfParser(scene, undefined, iface);
    scene.grid.visible = true;
    div.appendChild(scene.getDomElement());
    scene.setSize(div.clientWidth, div.clientHeight);
    function animate() {
      id = requestAnimationFrame(animate);
      scene.render();
    }
    animate();
  };
}

function stop(div: HTMLDivElement) {
  return () => {
    cancelAnimationFrame(id);
    if (div.firstChild) div.removeChild(div.firstChild);
  };
}

export { connect, stop };
